<!DOCTYPE html>
<html lang='en'>
	<head>
		<meta charset='utf-8' />
		<script type="text/javascript" src="__PUBLIC__/js/jquery.js"></script>
		<script type="text/javascript">
			var flag = true;
			var runing = false;
			push_start();
			function sendPush(url, vars, callback) {
				return $.ajax({
					type : "POST",
					url : url,
					data : vars + "&ajax=1",
					dataType : "json",
					success : callback
				});
			}

			function hide_msg($obj) {
				runing = true;
				setTimeout(function() {
					$($obj).find("div.alert").remove();
					if ($($obj).find("div.alert").length) {
						hide_msg($obj);
					} else {
						runing = false;
					}
				}, 3000)
			}

			function show_msg(info) {
				if (info != "no-data") {
					html = "<div class=\"col-sm-3 alert alert-info fade in\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">×</button><span>" + info + "</span></div>"
					$obj = $("#push_msg", parent.document);
					$obj.prepend(html);
					if (runing == false) {
						hide_msg($obj);
					}
				}
			}

			function push_start() {
				sendPush("{:U('push/server')}", '', function(data) {
					show_msg(data.info);
					if (flag) {
						push_start();
					}
				});
			}

			function push_stop() {
				flag = false;
			}
		</script>
	</head>
</html>